/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.repair.service;

import org.springblade.modules.repair.dto.MalfunctionRescueSaveDTO;
import org.springblade.modules.repair.dto.RescueArriveDTO;
import org.springblade.modules.repair.dto.plan.PlanAddUserDTO;
import org.springblade.modules.repair.entity.MaintainMalfunctionRescue;
import org.springblade.modules.repair.vo.*;
import org.springblade.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.repair.vo.plan.PlanRescueDetailVO;
import org.springblade.modules.repair.vo.rescue.DispatcherPageReqVO;
import org.springblade.modules.repair.vo.rescue.DispatcherPageRespVO;
import org.springblade.modules.repair.vo.rescue.DispatcherStatisticsVO;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 救援工单明细 服务类
 *
 * @author ysq
 * @since 2023-02-25
 */
public interface IMaintainMalfunctionRescueService extends BaseService<MaintainMalfunctionRescue> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param
	 * @return
	 */
	IPage<MalfunctionRescueHistoryPageVO> selectMaintainMalfunctionRescueHistoryPage(IPage<MalfunctionRescueHistoryPageVO> page, Long elevatorId);

    List<MalfunctionRescueHomeListVO> malfunctionRescueHomeList(Long userId, String longitude, String latitude, Date startDate, Date endDate, Boolean sortByPlanDateASC);

	MalfunctionRescueDetailVO malfunctionRescueDetail(Long planId);

	Boolean malfunctionRescueFinish(MalfunctionRescueSaveDTO saveDTO);

	/**
	 * 从已出发变为已到达
	 * @return 是否成功
	 */
	boolean rescueConfirm(RescueArriveDTO arriveRequest);

	/**
	 * 地图-救援人员详情
	 * @param planId
	 * @return
	 */
	List<MapUserInfoDetailVO> mapUserDetails(Long planId);

	/**
	 * 救援工单详情
	 * @param planId
	 * @return
	 */
	RescueOrderDetail rescueDetail(Long planId);

	/**
	 * 判断救援人员是否在出发中
	 * @param userId
	 * @return
	 */
	boolean rescueUserRunning(Long userId);

	/**
	 * 根据电梯获取救援任务
	 * @param type 1:查询进行中的，2：历史已经完成的
	 * @param elevatorId 电梯id
	 * @return 数据集
	 */
	Map<String, Object> getElevatorOfRescueInfo(Integer type, Long elevatorId);

	/**
	 * 新增救援工单
	 * @param maintainMalfunctionRescue
	 * @return
	 */
    Long addRescuePlan(MaintainMalfunctionRescue maintainMalfunctionRescue);

	/**
	 * 救援撤销
	 * @param planId
	 * @return
	 */
	Boolean rescueCancel(Long planId);

	/**
	 * 救援工单分配人员
	 * @param planAddUserDTO
	 * @return
	 */
	Boolean planAddUser(PlanAddUserDTO planAddUserDTO);

	/**
	 * 获取救援工单详情
	 * @param planId
	 * @return
	 */
	PlanRescueDetailVO getRescueDetail(Long planId);

	List<MapUserInfoVO> mapRescueBuildingRecentlyUser(Long buildingId, List<String> vehicle, List<Integer> workStatus, Integer distance, List<Integer> isSign, Integer searchMin, Long elevatorId, String keyword);

	List<MapUserInfoVO> mapRescueBuildingRecentlyMaintainUser(Long buildingId, List<String> vehicle, List<Integer> workStatus, Integer distance, List<Integer> isSign, Integer searchMin, Long elevatorId, String keyword);

	List<MapUserInfoVO> mapRescueBuildingRecentlyBuildingUser(Long buildingId, List<String> vehicle, List<Integer> workStatus, Integer distance, List<Integer> isSign, Integer searchMin, Long elevatorId, String keyword);

	/**
	 * 调度分页
	 * @param dispatcherPageReqVO
	 * @param page
	 * @return
	 */
	IPage<DispatcherPageRespVO> dispatcherPage(DispatcherPageReqVO dispatcherPageReqVO, IPage<DispatcherPageRespVO> page);

	/**
	 * 救援工单详情列表
	 * @param buildingId
	 * @param elevatorId
	 * @return
	 */
	List<RescueDetailVO> rescueDetailListByElevatorId(Long buildingId, Long elevatorId);

	/**
	 * 调度统计
	 * @return
	 */
	DispatcherStatisticsVO dispatcherStatistics();

	/**
	 * 判断是否有关联的维修单
	 * @param id
	 * @return
	 */
	Boolean hasRelaMalOrder(Long id);

	/**
	 * 上报维修
	 * @param repairWorkVO
	 * @return
	 */
	HashMap<String, Object> reportMal(RepairWorkVO repairWorkVO);

	/**
	 * 催办
	 * @param planId
	 * @return
	 */
	Boolean reminder(Long planId);
}
